import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *

class RadioDemo(QWidget):
    def __init__(self,parent=None):
        super(RadioDemo,self).__init__(parent)
        layout=QHBoxLayout()
        self.btn1=QRadioButton("btn1")
        self.btn1.setChecked(True)
        self.btn1.toggled.connect(lambda:self.btnstate(self.btn1))
        layout.addWidget(self.btn1)
        self.setLayout(layout)
        self.setWindowTitle("Radio demo")
    def btnstate(self,btn):
        if btn.text()=="btn1":
            if btn.isChecked()==True:
                print(btn.text()+"is selected")
            else:
                print(btn.text()+"is deselected")
if __name__ == '__main__':
    app=QApplication(sys.argv)
    win=RadioDemo()
    win.show()
    sys.exit(app.exec_())